using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace Coding4Fun.Phone.Controls.Helpers
{
	public class ColorSpace
	{
		private const byte byte_0 = 0;
		private const byte byte_1 = 255;
		private const byte byte_2 = 255;
		private static readonly Color[] color_0 = new Color[]
		{
			Color.FromArgb(255, 255, 0, 0),
			Color.FromArgb(255, 255, 255, 0),
			Color.FromArgb(255, 0, 255, 0),
			Color.FromArgb(255, 0, 255, 255),
			Color.FromArgb(255, 0, 0, 255),
			Color.FromArgb(255, 255, 0, 255)
		};
		private static readonly Color[] color_1 = new Color[]
		{
			Color.FromArgb(255, 76, 76, 76),
			Color.FromArgb(255, 225, 225, 225),
			Color.FromArgb(255, 149, 149, 149),
			Color.FromArgb(255, 178, 178, 178),
			Color.FromArgb(255, 29, 29, 29),
			Color.FromArgb(255, 105, 105, 105)
		};
		public static LinearGradientBrush GetColorGradientBrush(Orientation orientation)
		{
			return ColorSpace.smethod_0(orientation, ColorSpace.color_0);
		}
		public static LinearGradientBrush GetBlackAndWhiteGradientBrush(Orientation orientation)
		{
			return ColorSpace.smethod_0(orientation, ColorSpace.color_1);
		}
		private static LinearGradientBrush smethod_0(Orientation orientation_0, params Color[] color_2)
		{
			LinearGradientBrush linearGradientBrush = new LinearGradientBrush();
			float num = 1f / (float)color_2.Length;
			for (int i = 0; i < color_2.Length; i++)
			{
				PresentationFrameworkCollection<GradientStop> arg_43_0 = linearGradientBrush.get_GradientStops();
				GradientStop gradientStop = new GradientStop();
				gradientStop.set_Offset((double)(num * (float)i));
				gradientStop.set_Color(color_2[i]);
				arg_43_0.Add(gradientStop);
			}
			PresentationFrameworkCollection<GradientStop> arg_82_0 = linearGradientBrush.get_GradientStops();
			GradientStop gradientStop2 = new GradientStop();
			gradientStop2.set_Offset((double)(num * (float)color_2.Length));
			gradientStop2.set_Color(color_2[0]);
			arg_82_0.Add(gradientStop2);
			if (orientation_0 == null)
			{
				linearGradientBrush.set_StartPoint(new Point(0.0, 1.0));
				linearGradientBrush.set_EndPoint(default(Point));
			}
			else
			{
				linearGradientBrush.set_EndPoint(new Point(1.0, 0.0));
			}
			return linearGradientBrush;
		}
		public static Color GetColorFromHueValue(float position)
		{
			position /= 360f;
			position *= (float)(ColorSpace.color_0.Length * 255);
			byte b = (byte)(position % 255f);
			byte b2 = 255 - b;
			switch ((int)position / 255)
			{
			case 0:
				return Color.FromArgb(255, 255, b, 0);
			case 1:
				return Color.FromArgb(255, b2, 255, 0);
			case 2:
				return Color.FromArgb(255, 0, 255, b);
			case 3:
				return Color.FromArgb(255, 0, b2, 255);
			case 4:
				return Color.FromArgb(255, b, 0, 255);
			case 5:
				return Color.FromArgb(255, 255, 0, b2);
			default:
				return Colors.get_Black();
			}
		}
		public static string GetHexCode(Color color_2)
		{
			return string.Format("#{0}{1}{2}", color_2.get_R().ToString("X2"), color_2.get_G().ToString("X2"), color_2.get_B().ToString("X2"));
		}
		public static Color ConvertHsvToRgb(float float_0, float saturation, float value)
		{
			float_0 /= 360f;
			if (saturation <= 0f)
			{
				byte b = (byte)(value * 255f);
				return Color.FromArgb(255, b, b, b);
			}
			if (float_0 >= 1f)
			{
				float_0 = 0f;
			}
			float_0 = 6f * float_0;
			int num = (int)Math.Floor((double)float_0);
			byte b2 = (byte)Math.Round((double)(255f * value) * (1.0 - (double)saturation));
			byte b3 = (byte)Math.Round((double)(255f * value) * (1.0 - (double)(saturation * (float_0 - (float)num))));
			byte b4 = (byte)Math.Round((double)(255f * value) * (1.0 - (double)saturation * (1.0 - (double)(float_0 - (float)num))));
			byte b5 = (byte)Math.Round((double)(255f * value));
			switch (num)
			{
			case 0:
				return Color.FromArgb(255, b5, b4, b2);
			case 1:
				return Color.FromArgb(255, b3, b5, b2);
			case 2:
				return Color.FromArgb(255, b2, b5, b4);
			case 3:
				return Color.FromArgb(255, b2, b3, b5);
			case 4:
				return Color.FromArgb(255, b4, b2, b5);
			case 5:
				return Color.FromArgb(255, b5, b2, b3);
			default:
				return Color.FromArgb(0, 0, 0, 0);
			}
		}
	}
}
